package com.pay.dextest;

import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

import java.util.concurrent.ExecutorService;

public abstract class BaseYSFRunnable implements Runnable {
    protected Context mContext = ContextUtil.getContext();
    protected InjectMessageHandler mInjectMessageHandler = InjectMessageHandler.INSTANCE;
    protected ExecutorService mExecutorService;
    protected long mId;
    protected ContentResolver mContentResolver;
    protected Cursor mCursor;
    protected Uri mUri;
    public BaseYSFRunnable(ExecutorService executorService,String content) {
        mExecutorService = executorService;
        mContentResolver = mContext.getContentResolver();
        mUri = Uri.parse(content);
        mExecutorService.execute(this);
    }
    protected synchronized void updateDb(String output) {
        ContentValues contentValues = new ContentValues();
        Uri contentUris = ContentUris.withAppendedId(mUri, mId);
        contentValues.put("_output", output);
        contentValues.put("_is_ok", 1);
        mContentResolver.update(contentUris, contentValues, null, null);
    }
}
